<?php 
namespace Home\Controller;
use Think\Controller;
/**
* 上传图片处理器
*/
class PhotoController extends CommonController{
	public function add(){
		if (IS_POST) {
			set_time_limit (0);
			$user_id=1;
	        $dir="/Public/Uploads/active/";
	        if(!file_exists($dir)){
	            mkdir($dir,0777,true);
	        }
	        $imgs = I('post.img');
	        $base64_body = substr(strstr($imgs[0],','),1);
        	$new_file = "Public/Uploads/active/".$user_id.time().".jpg";
        	$res=file_put_contents($new_file, base64_decode($base64_body));
	    	$active['user_id'] = $user_id;
	    	$img=__ROOT__."/".$new_file;
	        if ($res) {
            	return show(1,$new_file);
	        }else{
	            return show(0,'网络超时，请重试！');
	        }
		}
	}
}